<?php

namespace App\Services\DBHelpers;


use App\Models\Store\WaxSkinRecord;
use App\Services\Utils\Transaction;

class FixWaxSkinRecordOilValue

{

    /**
     * @deprecated - 刘志明反馈说 App 提交的油分数据为错误的值，需要把油分数据用 100 - 当前值刷新数据
     *
     * \App\Services\DBHelpers\FixWaxSkinRecordOilValue::run()
     *
     * @throws \Exception
     */
    public static function run()
    {
        return "2018/10/25 09:08:45 线上已同步";

        $records = (new WaxSkinRecord)
            ->where('itemsid', WaxSkinRecord::ITEMSID_OIL)
            ->select(['id', 'value'])
            ->cursor();

        Transaction::handle(function () use ($records) {
            /** @var WaxSkinRecord $record */
            foreach ($records as $record) {
                $new_value = 100 - $record->value;

                echo "id: {$record->id} value is {$record->value} => $new_value \n" ;

//                $record->update(['value' => $new_value]);
            }
        });
    }

}